<?php
require('lib/verify.php');
require('lib/has_char.php');
require('lib/is_approved.php');

$system_id = $system["system_id"];

$raid_id = $_GET["id"];

$chara = $character["character_id"];;

//need to check if we're already signed up

$sql = "select * from wm_scheduled_signups where scheduled_signup_raid = $raid_id and scheduled_signup_character = $chara";
$result = $db->query($sql);

if($db->num_rows($result)==0) {
  header("Location: signup.php?id=$raid_id&error=You're+not+signed+up+for+that+raid.");
  exit;
}

$sql = "delete from wm_scheduled_signups where scheduled_signup_character = $chara and scheduled_signup_raid = $raid_id and scheduled_signup_system_id = $system_id";

$result = $db->query($sql);

$now = time();

$log_entry = "$chara un-signed up for $raid_id";

$sql = "insert into wm_logs (log_character, log_type, log_description, log_datetime, log_system_id) values ($chara, 'Signup', '$log_entry', FROM_UNIXTIME($now), $system_id)";
$result = $db->query($sql);


header("Location: signup.php?id=$raid_id");

?>